Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add abstractions for flow builder create test #298

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

GitEvil
Copy link
Contributor

@GitEvil GitEvil commented Feb 3, 2025

Changes to ATS for NEXT-39672 - Flow Builder Create test

src/page-objects/administration/FlowBuilderDetail.ts Outdated Show resolved Hide resolved
src/page-objects/administration/FlowBuilderListing.ts Outdated Show resolved Hide resolved
src/tasks/shop-admin/Flow/CreateFlow.ts Outdated Show resolved Hide resolved
src/tasks/shop-admin/Flow/CheckFlow.ts Outdated Show resolved Hide resolved
src/page-objects/administration/FlowBuilderCreate.ts Outdated Show resolved Hide resolved
src/page-objects/administration/FlowBuilderListing.ts Outdated Show resolved Hide resolved
src/tasks/shop-admin/Flow/CheckFlow.ts Outdated Show resolved Hide resolved
import { type Page, type Locator } from '@playwright/test';

/**
* Returns the locator for a list item on a select field's result list.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow I don't like the approach of introducing a new silo for lots or functions where the purpose of the class is not specific enough. Let's think about it again.

I have already an idea:

  • create a service like CustomFieldCard which inject a page object so that we can manage there some card specific functions like getCustomFieldCardContent(). And use the functions within page objects which want to use it with:
import { getCustomFieldCardContent } from '../../services/ShopwareUIHelpers.ts';

export class ProductDetail implements PageObject {
    // ...

    public getCustomFieldCardContent(selectField: Locator, listItem: string) {
        return getCustomFieldCardContent(this.page, locator, listItem);
    }
}

so within your test you could call then:

const customFieldLocators = await AdminProductDetail.getCustomFieldCardContent(selectField, listItem: string);

@vanpham-sw and @yusufttur what do you think about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@frobel I purposefully added the function to the UIHelpers class so that it would not have to be declared in every page object. With this test alone, we check 3-5 different detail pages and would thus have to add the function to each page object. I just found it easier to put it into the Helpers class once.

Copy link
Contributor

@vanpham-sw vanpham-sw Feb 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GitEvil Even though this is a clever solution, I'd agree with Florian not to do it this way. This can lead to complexity if the functions are not cohesively related or if the class becomes a "catch-all" for unrelated functionalities. If the purpose is not specific, the class may become overly complex and difficult to maintain.

Have you tried below approach?

  • Create a CustomFieldCard page object class contains getResultListItem & getCustomFieldCardContent
  • detail pages: class ProductDetail extends CustomFieldCard implements PageObject

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants